<?php
class Block_Core_Form_Abstract
    extends Block_Core_Main_Content
{
    protected $_fieldsets = array();

    protected $_formName;

    protected $_formId;

    public function __construct()
    {
        parent::__construct();
        $this->setTemplate('form/template.phtml');
    }

    public function getFormId()
    {
        return $this->_formId;
    }

    public function setFormId($formId)
    {
        $this->_formId = $formId;
        return $this;
    }

    public function getFormName()
    {
        return $this->_formName;
    }

    public function toHtml()
    {
        $this->_prepareData();
        $this->_prepareForm();
        parent::toHtml();
    }

    protected function _prepareForm()
    {
        return $this;
    }

    protected function _prepareData()
    {
        return $this;
    }

    public function getFieldset()
    {
        return $this->_fieldsets;
    }

    public function addFieldset(Block_Core_Form_Fieldset_Abstract $fieldset)
    {
        $this->_fieldsets[] = $fieldset;
        return $this;
    }

    public function getFormatedNameValue($name)
    {
        return $name;
    }

    public function getFieldHtml($field)
    {
        $f = substr($field->getType(), 0, 1);
        $s = substr($field->getType(), 1);
        $type = strtoupper($f).$s;
        $class = 'Block_Core_Form_Element_'.$type;
        $class = new $class($field->getData());

        return $class->toHtml();
    }
}